# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/suspend-handler)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/sources/suspend-handler)

if (ENABLE_POWER_MANAGEMENT)
	if(WIN32)
		list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_HEADER_DIR}/SuspendHandlerWindows.h)
		list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_SOURCE_DIR}/SuspendHandlerWindows.cpp)
	else()
		if(APPLE)
			find_library(APPKIT_FRAMEWORK AppKit REQUIRED)
			list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_HEADER_DIR}/SuspendHandlerMacOS.h)
			list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_SOURCE_DIR}/SuspendHandlerMacOS.mm)
		else()
			list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_HEADER_DIR}/SuspendHandlerLinux.h)
			list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_SOURCE_DIR}/SuspendHandlerLinux.cpp)
		endif()
	endif()
else()
	list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_HEADER_DIR}/SuspendHandlerDummy.h)
	list(APPEND SUSPEND_HANDLER_SOURCES ${CURRENT_SOURCE_DIR}/SuspendHandlerDummy.cpp)
endif()

add_library(suspend-handler OBJECT ${SUSPEND_HANDLER_SOURCES} )
target_link_libraries(suspend-handler PUBLIC ${PIPEWIRE_LIBRARIES} ${APPKIT_FRAMEWORK} Qt${Qt_VERSION}::Core Qt${Qt_VERSION}::Network)

if(ENABLE_POWER_MANAGEMENT AND UNIX)
	if(NOT APPLE)
		set_property(TARGET suspend-handler PROPERTY CXX_STANDARD 17)
		target_link_libraries(suspend-handler PUBLIC ${PIPEWIRE_LIBRARIES} sdbus-c++)
	endif()
endif()
